home *** CD-ROM | disk | FTP | other *** search
- /*
- File: SampleLibrary.h
-
- Contains: Interface for everything that the CPlusSampleLibrary exports including
- the TTrafficLight class.
-
- Copyright: © 1993 by Apple Computer, Inc., all rights reserved.
-
- */
-
-
- #ifndef __SAMPLELIBRARY__
- #define __SAMPLELIBRARY__
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- /*————————————————————————————————————————————————————————————————————————————————————
- DEFINITIONS AND CONSTANTS
- ————————————————————————————————————————————————————————————————————————————————————*/
-
- #define rWindow 128 /* application's window */
- #define rStopRect 128 /* rectangle for Stop light */
- #define rGoRect 129 /* rectangle for Go light */
-
- #define mLight 131 /* Light menu */
- #define iStop 1
- #define iGo 2
-
- // k<classname>ID needs to be declared, and is used as the classes class ID
- // when the shraed library is built
-
- #define kTrafficLightLibID "slm:samp$CPlusTrafficLightLib"
- #define kTTrafficLightID "slm:samp$TTrafficLight,1.1"
-
- #ifdef __cplusplus
-
- class TTrafficLight;
-
- /*————————————————————————————————————————————————————————————————————————————————————
- class TTrafficLight
- ————————————————————————————————————————————————————————————————————————————————————*/
-
- class TTrafficLight : public TDynamic {
- public:
- TTrafficLight();
- virtual ~TTrafficLight();
-
- // public virtual methods
-
- virtual Boolean IsValid() const; // Override
-
- virtual Boolean GetLightState() const; // returns the state of the light
- virtual void SetLightState( Boolean state ); // set it to new state
- virtual void DrawLight(); // displays the light
- virtual void AdjustMenus( Boolean update );
- virtual void DoMenuCommand( short menuItem );
-
- protected:
- static Boolean GoGetRect( short rectID, Rect *theRect );
-
- private:
- Boolean fLightState; // 0:indicates OFF, 1:indicates ON
- Rect fStopRect; // rectangle for stop light
- Rect fGoRect; // rectangle for go rectangle
- WindowPtr fWindow; // objects grafport and window
- };
-
- #endif
-
- #endif